package org.demo.patten.composite;

import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhuj
 * @date 2025/3/22
 * @apiNote
 */
@ToString
@EqualsAndHashCode
public class Folder implements FileSystemNode {
    private String name;
    private List<FileSystemNode> children = new ArrayList<>();

    public Folder(String name) {
        this.name = name;
    }

    public void add(FileSystemNode node) {
        children.add(node);
    }

    @Override
    public void show() {
        System.out.println("文件夹：" + name);
        children.forEach(child -> child.show());
    }
}
